<template>
  <div>
    <p v-show="projectInfoObj.contract.contractUrl">
      <a :href="projectInfoObj.contract.contractUrl" target="_blank">劳动合同</a>
    </p>

    <a-space class="float_right" v-if="editClkFlag">
      <a-button type="primary" @click="saveBtnClkFn" :loading="saveBtnLoading">保存</a-button>
      <a-button @click="cancelBtnClkFn">取消</a-button>
    </a-space>

    <a-button type="primary" style="margin-top:12px" @click="formEditBtnClkFn" v-else :disabled="contractInfos.contract ? (contractInfos.contract.status == 'Process' || contractInfos.contract.status == 'Success') : ''">编辑</a-button>

    <div style="margin-top：50px;">
      <a-descriptions title=" " v-if="!editClkFlag" class="descriptions_show">
        <a-descriptions-item label="入职项目">{{projectInfoObj.projectName}}</a-descriptions-item>
        <a-descriptions-item label="入职时间">{{projectInfoObj.entryTime | dateFormatFilter }}</a-descriptions-item>
        <a-descriptions-item label="合同类型">{{contractInfos.contract ? contractInfos.contract.contractType : '暂无' | contractTypeFilter}}</a-descriptions-item>
        <a-descriptions-item label="是否电子合同">{{contractInfos.contract ? contractInfos.contract.electronicIf : '' | electronicIfFilter}}</a-descriptions-item>
        <a-descriptions-item label="电子合同模板ID">{{projectInfoObj.contractTemplateId ? projectInfoObj.contractTemplateId : '暂无'}}</a-descriptions-item>
        <a-descriptions-item label="签署状态">{{contractInfos.contract ? contractInfos.contract.status : '' | statusFilter}}</a-descriptions-item>
        <a-descriptions-item label="合同开始时间">{{contractInfos.contract ? contractInfos.contract.contractBeginDate : '' | dateFormatFilter}}</a-descriptions-item>
        <a-descriptions-item label="合同结束时间">{{contractInfos.contract ? contractInfos.contract.contractEndDate : '' | dateFormatFilter}}</a-descriptions-item>
        <a-descriptions-item label="入职部门">{{contractInfos.contract ? (!contractInfos.contract.deptName ? '暂无' : contractInfos.contract.deptName) : '暂无'}}</a-descriptions-item>
        <a-descriptions-item label="入职岗位">{{contractInfos.contract ? (!contractInfos.contract.postName  ? '暂无' : contractInfos.contract.postName) : '暂无'}}</a-descriptions-item>
        <a-descriptions-item label="试用期">{{contractInfos.contract ? contractInfos.contract.trialPeriodMonth : '' | trialPeriodMonthFilter}}</a-descriptions-item>
        <a-descriptions-item label="试用期薪资">{{contractInfos.contract ? contractInfos.contract.trialSalaryAmt : '' | salaryAmtFilter}}</a-descriptions-item>
        <a-descriptions-item label="基本薪资">{{contractInfos.contract ? contractInfos.contract.salaryAmt : '' | salaryAmtFilter}}</a-descriptions-item>
        <a-descriptions-item label="工作制">{{contractInfos.contract ? contractInfos.contract.jobDuty : '' | jobDutyFilter}}</a-descriptions-item>
        <a-descriptions-item label="用工性质">{{contractInfos.contract ? contractInfos.contract.jobNature : '' | jobNatureFilter}}</a-descriptions-item>
        <a-descriptions-item label="发起完成日期">{{contractInfos.contract ? contractInfos.contract.signEndTime : '' | dateFormatFilter}}</a-descriptions-item>
        <a-descriptions-item label="发起签约日期">{{contractInfos.contract ? contractInfos.contract.signStartTime : '' | dateFormatFilter}}</a-descriptions-item>
        <a-descriptions-item label="是否有亲朋同行" :span="2">
          <span>{{!isEmptyFn(colleagueListData) ? '是' : '否'}}</span>
        </a-descriptions-item>
      </a-descriptions>

      <!-- 编辑状态 -->
      <div class="editForm_div" v-if="editClkFlag">
        <a-descriptions title=" " :layout="layoutType" class="necessary" :class="[isPeriod == 1 ? 'require' : '', editForm.electronicIf ? 'required' : '']">
          <a-descriptions-item label="入职项目">
            <!-- <a-input v-if="editClkFlag" :default-value="projectInfoObj.projectName" placeholder="请输入" @change="(e) => entryPositionIptOnChange(e.target.value)" :disabled=""></a-input> -->
            <a-select allowClear show-search placeholder="请选择入职项目" option-filter-prop="children" :style="widthOption" @change="entryProHandleChange" @focus="entryProFocusFn" :disabled="contractInfos.userInfo == 'OnJob'" :default-value="projectInfoObj.projectName" :getPopupContainer="(triggerNode) => triggerNode.parentNode">
              <a-select-option v-for='(item, index) in entrySelectData' :key="index" :value="item.projectName" :data="{id: item.projectId, value: item.projectName}">
                {{item.projectName}}
              </a-select-option>
            </a-select>
          </a-descriptions-item>

          <a-descriptions-item label="入职时间">
            <a-date-picker :style="widthOption" @change="entryPositionDateOnChange" :default-value="projectInfoObj.entryTime ? moment(Number(projectInfoObj.entryTime)) : ''" />
          </a-descriptions-item>

          <a-descriptions-item v-for="(value, key, index) in contractInfos.contractSimplify" :label="labelFilter(key)" :key="index">
            <a-input v-if="editClkFlag && (key == 'postName' || key == 'deptName' || key == 'trialPeriodMonth' || key == 'salaryAmt' || key == 'trialSalaryAmt' || key == 'contractTemplateId')" :default-value="valueFilterFn(value,key)" placeholder="请输入" @change="(e) => iptOnChange(e.target.value, key)" allow-clear :maxLength="key == 'trialPeriodMonth' ? 2 : null" :suffix="key == 'trialPeriodMonth' ? '/月' : ''" :style="widthOption" :disabled="!editForm.electronicIf && key == 'contractTemplateId'"></a-input>

            <a-date-picker :style="widthOption" v-else-if="editClkFlag && (key == 'signStartTime' || key == 'signEndTime' || key == 'contractBeginDate' || key == 'contractEndDate')" @change="(date, dateString) => dateOnChange(dateString, key)" :default-value="value ? moment(Number(value)) : ''" :disabled="key == 'signEndTime' || key == 'signStartTime'" />

            <a-radio-group name="radioGroup" v-else-if="editClkFlag && (key == 'electronicIf' || key == 'contractType')" :default-value="valueFilterFn(value, key)" @change="e => radioChangeFn(e, key)">
              <a-radio v-for="(item, index) in radioDataFilterFn(key)" :key="index" :value="item.key">{{item.value}}</a-radio>
            </a-radio-group>

            <a-select v-else-if="editClkFlag && (key == 'status' || key == 'jobNature' || key == 'jobDuty')" :style="widthOption" @change="selectHandleChange" placeholder="请选择" allowClear :default-value="itemFilterFn(value, key)" show-search option-filter-prop="children" :getPopupContainer="(triggerNode) => triggerNode.parentNode" :disabled="key == 'status'">
              <a-select-option v-for="(item, index) in selectDataByKey(key)" :key="index" :labels="key" :value="item.key">
                {{item.val}}
              </a-select-option>
            </a-select>
          </a-descriptions-item>

          <a-descriptions-item label="是否有亲朋同行">
            <a-radio-group name="radioGroup" :key="projectInfoObjCpt.colleagueList.length != 0 ? 1 : 2" :default-value="projectInfoObjCpt.colleagueList.length != 0 ? 1 : 2" @change="colleagueListRedioChangeFn">
              <a-radio :value="1">
                是
              </a-radio>
              <a-radio :value="2">
                否
              </a-radio>
            </a-radio-group>
          </a-descriptions-item>
        </a-descriptions>
      </div>

      <!-- 同行人员表格 -->
      <a-descriptions title=" ">
        <template id="tem">
          <a-descriptions-item :span="2" class="my_desc_div" v-if="!isEmptyFn(contractData)">
            <div class="table_div">
              <a-table :columns="colleagueColumnsCpt" :dataSource="contractData" :pagination="false">
                <template v-for="col in colleagueColumnsCpt" :slot="col.dataIndex" slot-scope="text, record">
                  <a-input :key="col.key" v-if="record.editable" style="margin: -5px 0" :value="text" @change="e => handleChange(e.target.value, record.key, col.dataIndex)" />
                  <template v-else>{{text}}</template>
                </template>
                <template slot="opera" slot-scope="text, record">
                  <template v-if="record.editable">
                    <span v-if="record.isNew">
                      <a @click="saveRow(record.key, record, 0)">添加</a>
                      <a-divider type="vertical" />
                      <a-popconfirm title="是否要删除此行？" @confirm="remove(record.key, record, 0)">
                        <a>删除</a>
                      </a-popconfirm>
                    </span>
                    <span v-else>
                      <a @click="saveRow(record.key, record, 1)">保存</a>
                      <a-divider type="vertical" />
                      <a @click="cancle(record.key)">取消</a>
                    </span>
                  </template>
                  <span v-else>
                    <a @click="toggle(record.key)">编辑</a>
                    <a-divider type="vertical" />
                    <a-popconfirm title="是否要刪除此行？" @confirm="remove(record.key, record, 1)">
                      <a>删除</a>
                    </a-popconfirm>
                  </span>
                </template>
              </a-table>
              <a-button v-if="editClkFlag" style="width: 100%; margin-top: 16px; margin-bottom: 8px" type="dashed" icon="plus" @click="newMember">新增成员</a-button>

            </div>
          </a-descriptions-item>
        </template>
      </a-descriptions>
    </div>
  </div>
</template>

<script>
import { transferDate, isEmpty, dateToTimestamp } from '@/utils/util'
import datas from '@/utils/data'
import moment from 'moment'
import { colleagueAddOrUpdateApi, colleagueDelByIdApi, contractAddOrUpdateApi, getProjectListForSelectApi, bindProjectApi } from '@/services/employeeDetail'

let $projectId
let $isEntryPro

export default {
  name: "tabs2",
  props: {
    contractInfos: Object,
    projectInfoObj: Object,
    colleagueListData: Array
  },
  filters: {
    dateFormatFilter (val) {
      if (val) {
        return transferDate(val, 0)
      } else {
        return '暂无  '
      }

    },
    contractTypeFilter (val) {
      switch (val) {
        case 1:
          return '固定期限'
        case 2:
          return '无固定期限'
        default:
          return '暂无'
      }
    },
    electronicIfFilter (val) {
      switch (val) {
        case true:
          return '是'
        case false:
          return '否'
        default:
          return '暂无'
      }
    },
    jobNatureFilter (val) {
      switch (val) {
        case 1:
          return '正式工'
        case 2:
          return '临时工'
        case 3:
          return '实习生'
        case 4:
          return '其他'
        default:
          return '暂无'
      }
    },

    jobDutyFilter (val) {
      switch (val) {
        case 1:
          return '标准工时制'
        case 2:
          return '不定时工作制'
        case 3:
          return '综合工时制'
        default:
          return '暂无'
      }
    },

    statusFilter (type) {
      switch (type) {
        case 'Corvidae':
          return '待完善'
        case 'Wait':
          return '待签署'
        case 'Process':
          return '签署中'
        case 'Success':
          return '签署成功'
        case 'Fail':
          return '签署失败'
        case 'Refuse':
          return '拒签'
        case 'Cancel':
          return '取消签署'
        default:
          return '暂无'
      }
    },

    trialPeriodMonthFilter (val) {
      return val ? val + '个月' : '暂无'
    },

    salaryAmtFilter (val) {
      if (val) {
        return val + '元'
      } else {
        if (val == 0) {
          return 0
        } else {
          return '暂无'
        }

      }
    }
  },
  watch: {
    colleagueListData (n) {
      this.contractData = n
    }
  },
  created () {
    // console.log("this.colleagueListData", this.colleagueListData)
    // console.log('projectInfoObj', this.projectInfoObj)
    // console.log('contractInfos', this.contractInfos) // 包含两个对象：contract(包含全部字段) contractSimplify(删除无用字段)

    if (this.contractInfos.contract) {
      if (this.contractInfos.contract.contractType == 1) {
        this.isPeriod = 1
      } else {
        this.isPeriod = 2
      }
    }

    if (this.projectInfoObj) {
      $projectId = this.projectInfoObj.project.id
      this.projectInfoObj.projectName ? $isEntryPro = true : $isEntryPro = false
    }

    if (this.colleagueColumns) {
      if (this.colleagueColumns.length > 5) {
        this.colleagueColumns = this.colleagueColumns.slice(0, 5)
      }
    }

    this.editForm = { ...this.contractInfos.contract, 'entryProName': this.projectInfoObj.projectName, "entryDate": this.projectInfoObj.entryTime }

    this.editForm.contractTemplateId = this.projectInfoObj.contractTemplateId

    this.editForm.electronicIf ? '' : this.editForm.contractTemplateId = ''

  },
  data () {
    this.cacheData = this.colleagueListData.map((item) => ({ ...item }));
    return {
      contractData: this.colleagueListData,
      editClkFlag: false,
      editingKey: "",
      layoutType: "horizontal",
      colleagueColumns: datas.colleagueListColumns,
      editForm: {
        electronicIf: false
      },
      entrySelectData: [],
      widthOption: 'width:202.5px',
      isPeriod: null,
      saveBtnLoading: false
    };
  },
  computed: {
    colleagueColumnsCpt () {
      let _arr
      if (this.colleagueColumns) {
        _arr = this.colleagueColumns.slice(0, this.colleagueColumns.length - 1)
      }
      return _arr
    },

    projectInfoObjCpt () {
      return this.projectInfoObj
    }
  },
  methods: {
    moment,

    entryProHandleChange (value, option) {
      !value ? $isEntryPro = false : $isEntryPro = true

      if (option) {
        $projectId = option.data.attrs.data.id
      }
    },

    bindProjectApiIvkFn (id) {
      bindProjectApi(this.$Storage.get('employDetail_employeeId'), id).then(res => {
        let { code, msg } = res.data

        if (code === 200) {
          this.$emit("updatesContractData");
        } else {
          this.$message.error(msg);
        }
      })
    },

    formEditBtnClkFn () {
      this.editClkFlag = true;
      this.layoutType = "vertical";

      this.colleagueColumns.push(
        {
          title: '操作',
          dataIndex: 'opera',
          scopedSlots: { customRender: 'opera' },
        }
      )

      if (Object.keys(this.contractInfos.contractSimplify).length == 0) {
        this.contractInfos.contractSimplify = {
          postName: '',
          deptName: '',
          trialPeriodMonth: '',
          salaryAmt: '',
          trialSalaryAmt: '',
          signStartTime: '',
          signEndTime: '',
          contractBeginDate: '',
          contractEndDate: '',
          electronicIf: false, // 为空默认否
          contractType: '',
          status: '',
          jobNature: '',
          jobDuty: '',
        }
        this.editForm.electronicIf = false
      }
    },

    entryProFocusFn () {
      getProjectListForSelectApi().then(res => {
        let { code, data, msg } = res.data

        if (code === 200) {
          let _arr = []
          if (data) {
            data.forEach(item => {
              if (item.projectName) {
                _arr.push(item)
              }
            })
          }

          this.entrySelectData = _arr
        } else {
          this.$message.error(msg);
        }
      })
    },

    cancelBtnClkFn () {
      this.editClkFlag = false;
      this.layoutType = "horizontal";
      this.colleagueColumns = this.colleagueColumns.slice(0, this.colleagueColumns.length - 1)

      this.contractData = this.colleagueListData
      this.editForm.hasColleague = true
    },

    // 编辑下保存
    saveBtnClkFn () {
      if (!$isEntryPro) {
        this.$message.error('请选择入职项目！')
        return
      }


      if (!this.editForm.entryDate || !this.projectInfoObj.entryTime) {
        this.$message.error('入职时间必填！')
        return
      }

      if (this.editForm.electronicIf) {
        if (!this.editForm.contractTemplateId) {
          this.$message.error('电子合同模板ID必填！')
          return
        }
      }

      if (this.editForm.signStartTime && this.editForm.signEndTime) {
        if (Number(dateToTimestamp(this.editForm.signStartTime)) > Number(dateToTimestamp(this.editForm.signEndTime))) {
          this.$message.error('发起完成日期应大于发起签约日期！')
          return
        }
      }

      if (!this.contractInfos.contract.contractBeginDate || !this.editForm.contractBeginDate) {
        this.$message.error('合同开始时间必填！')
        return
      }

      if (this.editForm.contractType == 1) {
        if (!this.contractInfos.contract.contractEndDate || !this.editForm.contractEndDate) {
          this.$message.error('合同结束时间必填！')
          return
        }
      }

      if (this.editForm.contractBeginDate && this.editForm.contractEndDate) {
        if (Number(dateToTimestamp(this.editForm.contractBeginDate)) > Number(dateToTimestamp(this.editForm.contractEndDate))) {
          this.$message.error('合同结束时间应大于合同开始时间！')
          return
        }
      }

      if (this.editForm.trialPeriodMonth) {
        if (this.editForm.trialPeriodMonth > 12) {
          this.$message.error('试用期不能大于12个月！')
          return
        } else {
          if (!/^\d+$/.test(this.editForm.trialPeriodMonth)) {
            this.$message.error('请输入整数！')
            return
          }
        }
      }


      let {
        entryDate, // 入职时间        
        deptName, // 入职部门
        postName, // 入职岗位
        contractType, // 合同类型
        status,// 签署状态
        electronicIf, // 电子合同 ?
        signStartTime, // 发起签约时间
        signEndTime, // 发起完成日期
        contractBeginDate, // 合同开始时间
        contractEndDate, // 合同结束时间
        salaryAmt, // 基本薪资
        trialSalaryAmt, // 试用期薪资
        trialPeriodMonth, // 试用期
        jobNature, // 用工性质
        jobDuty, // 工作制   
        contractTemplateId // 电子合同模板ID     
      } = this.editForm

      // console.log(
      //   // '---合同信息保存数据---',
      //   "entryDate", entryDate,
      //   deptName,
      //   postName,
      //   contractType,
      //   status,
      //   electronicIf,
      //   "signStartTime", signStartTime, // 发起签约时间
      //   "signEndTime", signEndTime, // 发起完成日期
      //   "contractBeginDate", contractBeginDate, // 合同开始时间
      //   "contractEndDate", contractEndDate, // 合同结束时间
      //   salaryAmt, // 基本薪资
      //   trialSalaryAmt, // 试用期薪资
      //   trialPeriodMonth, // 试用期
      //   jobNature, // 用工性质
      //   jobDuty, // 工作制
      // )

      let params = {
        employeeId: this.$Storage.get('employDetail_employeeId'), // employeeId 雇员ID
        contractId: this.$Storage.get('employeeContract_id') ? this.$Storage.get('employeeContract_id') : '', // 合同ID
        deptName,// 入职部门
        postName,// 入职岗位
        entryTimeStr: String(entryDate).indexOf('-') != -1 ? entryDate : transferDate(entryDate, 0),// 入职日期
        contractType,// 合同类型：1:固定期限,2:无固定期限
        isElectronic: electronicIf,// 是否电子合同(true是false否) 必 默认false
        status,// 合同签署状态（Corvidae：待完善,Wait：待签署,Process：签署中,Success：签署成功,Fail：签署失败,Refuse：拒签,Cancel：取消签署）
        jobNature,// 工作性质：1:正式工,2:临时工,3:实习生,4:其他
        jobDuty,// 工作制：1:标准工时制,2:不定时工作制,3:综合工时制
        contractBeginDateStr: String(contractBeginDate).indexOf('-') != -1 ? contractBeginDate : transferDate(contractBeginDate, 0), // 合同起始日期
        contractEndDate: String(contractEndDate).indexOf('-') != -1 ? contractEndDate : transferDate(contractEndDate, 0), // 合同终止日期
        trialPeriodMonth, // 试用期(单位月) 必
        trialSalaryAmt, // 试用期薪资
        signStartTimeStr: String(signStartTime).indexOf('-') != -1 ? signStartTime : transferDate(signStartTime, 0), // 发起签约日期
        signEndTimeStr: String(signEndTime).indexOf('-') != -1 ? signEndTime : transferDate(signEndTime, 0), // 签约完成日期
        salaryAmt, // 基本薪资 必
        eqbTemplateBaseId: Number(contractTemplateId) != 0 ? Number(contractTemplateId) : '' // 电子合同模板ID
      }

      // console.log('---params---', params)

      this.saveBtnLoading = true
      contractAddOrUpdateApi(params).then(res => {
        let { code, msg } = res.data;
        this.saveBtnLoading = false
        if (code === 200) {
          this.bindProjectApiIvkFn($projectId) // 入职项目切换是单独接口调用
          this.$message.success(msg);
          this.editClkFlag = false;
          this.layoutType = "horizontal";
          this.colleagueColumns = this.colleagueColumns.slice(0, this.colleagueColumns.length - 1)
        } else {
          this.$message.error(msg);
        }
      })
    },

    isEmptyFn (a) {
      return isEmpty(a)
    },

    labelFilter (str) {
      switch (str) {
        case 'deptName':
          return '入职部门'
        case 'postName':
          return '入职岗位'
        case 'contractType':
          return '合同类型'
        case 'electronicIf':
          return '是否电子合同'
        case 'status':
          return '签署状态'
        case 'jobNature':
          return '用工性质'
        case 'jobDuty':
          return '工作制'
        case 'contractBeginDate':
          return '合同开始时间'
        case 'contractEndDate':
          return '合同结束时间'
        case 'trialPeriodMonth':
          return '试用期'
        case 'salaryAmt':
          return '基本薪资'
        case 'trialSalaryAmt':
          return '试用期薪资'
        case 'signStartTime':
          return '发起签约日期'
        case 'signEndTime':
          return '发起完成日期'
        case 'contractTemplateId':
          return '电子合同模板ID'
      }
      return str
    },

    handleChange (value, key, column) {
      const newData = [...this.contractData];
      const target = newData.filter((item) => key === item.key)[0];
      if (target) {
        target[column] = value;
        this.contractData = newData;
      }
    },

    remove (key, data, type) {  // 现有数据删除是 1  添加后数据删除 0      
      const newData = this.contractData.filter(item => item.key !== key)
      this.contractData = newData

      if (data.id) {
        colleagueDelByIdApi(data.id).then(res => {
          let { code, msg } = res.data;

          if (code === 200) {
            this.$message.success(msg);
            this.$emit("updatesContractData"); // 如果全部删除 单选框定为否 点击是 显示新增表格                        
          } else {
            this.$message.error(msg);
          }
        })
      } else {
        this.$emit("updatesContractData");
      }
    },

    saveRow (key, data, type) {  // 新建保存0 编辑后保存1      
      let target = this.contractData.filter(item => item.key === key)[0]
      target.editable = false
      target.isNew = false

      // 编辑
      let { name, deptName, postName, mobile, id } = data;
      let params = {
        id: id ? id : '',
        employeeId: this.$Storage.get('employDetail_employeeId'),
        name,
        deptName,
        postName,
        mobile
      };


      colleagueAddOrUpdateApi(params).then((res) => {
        let { code, msg } = res.data;
        if (code === 200) {
          this.$message.success(msg);
          this.$emit('updatesContractData')
        } else {
          this.$message.error(msg);
        }
      });
    },

    cancle (key) {
      let target = this.contractData.filter(item => item.key === key)[0]
      target.editable = false
    },

    toggle (key) {
      let target = this.contractData.filter(item => item.key === key)[0]
      target.editable = !target.editable
      this.$forceUpdate()
    },

    newMember () {
      this.contractData.push({
        key: this.contractData.length + 1,
        deptName: "",
        mobile: "",
        name: "",
        postName: "",
        editable: true,
        isNew: true
      })
    },

    iptOnChange (e, key) {
      this.editForm[key] = e
    },

    entryPositionIptOnChange (e) {
      this.editForm.entryProName = e
    },

    valueFilterFn (value, key) {
      if (key == 'contractType') {
        return value
      } else if (key == 'status') {
        switch (value) {
          case "Corvidae":
            return '待完善'
          case "Wait":
            return '待签署'
          case "Process":
            return "签署中"
          case "Success":
            return "签署成功"
          case "Fail":
            return "签署失败"
          case "Refuse":
            return "拒签"
          case "Cancel":
            return "取消签署"
        }
      } else if (key == 'jobNature') {
        switch (value) {
          case 1:
            return '正式工'
          case 2:
            return '临时工'
          case 3:
            return '实习生'
          case 4:
            return '其他'
          default:
            return '无'
        }
      } else if (key == 'electronicIf') {
        switch (value) {
          case true:
            return 1
          case false:
            return 2
          default:
            return 2
        }
      } else if (key == 'jobDuty') {
        switch (value) {
          case 1:
            return '标准工时制'
          case 2:
            return '不定时工作制'
          case 3:
            return '综合工时制'
        }
      } else {
        return value
      }

    },

    dateOnChange (dateString, key) {
      this.editForm[key] = dateString
    },

    entryPositionDateOnChange (date, dateString) {
      this.editForm.entryDate = dateString
    },

    radioDataFilterFn (key) {
      if (key == 'electronicIf') {
        return datas.contractInfoEditIselectronic
      } else if (key == 'contractType') {
        return datas.contractInfoEditContractType
      }
    },

    colleagueListRedioChangeFn (e) {
      if (e.target.value == 1) { // 是
        this.newMember()
        this.contractData = this.colleagueListData
        this.editForm.hasColleague = true
      } else { // 否
        this.contractData = []
        this.$emit('updatesContractData', 'isEmpty')
        this.editForm.hasColleague = false
      }
    },

    selectHandleChange (value, option) {
      let _key = option.data.attrs.labels
      this.editForm[_key] = value
    },

    selectDataByKey (key) {
      if (key == 'status') {
        return datas.typeSelectArr
      } else if (key == 'jobNature') {
        return datas.jobNatureSelect
      } else if (key == 'jobDuty') {
        return datas.jobDutySelect
      }
    },

    getTargetValFn (value, _arr) {
      let _targetVal
      datas[_arr].forEach(item => {
        if (value == item.key) {
          _targetVal = item.val
        }
      })
      return _targetVal
    },

    itemFilterFn (value, key) {
      if (key == 'status') {
        return this.getTargetValFn(value, 'typeSelectArr1')
      } else if (key == 'jobNature') {
        return this.getTargetValFn(value, 'jobNatureSelect')
      } else if (key == 'jobDuty') {
        return this.getTargetValFn(value, 'jobDutySelect')
      }
    },

    radioChangeFn (e, key) {
      if (key == 'contractType') { // 合同类型
        this.editForm.contractType = e.target.value
        e.target.value == 1 ? this.isPeriod = 1 : this.isPeriod = 2 // 1-固定 2-非固定
      } else if (key == 'electronicIf') { // 电子合同
        this.editForm.electronicIf = e.target.value == 1 ? true : false // 1 是 2 否
        e.target.value == 1 ? this.editForm.contractTemplateId = this.projectInfoObj.contractTemplateId : this.editForm.contractTemplateId = ''
      }
    }
  },
};
</script>

<style scoped lang="less">
.infos {
  width: 100%;
  margin-left: 20px;
  & div:first-of-type {
    align-items: center;
    justify-content: flex-start;
  }
}

.descriptions_show {
  color: red;
  /deep/ .ant-descriptions-row:last-child {
    color: aqua;
    & > td {
      padding-bottom: 0 !important;
    }
  }
}

.basicInfo_div {
  color: #a2a2a2;
  & > p {
    margin-bottom: 0;
  }
}

.tabs_div {
  margin-top: 20px;
}

.editable-add-btn {
  margin: 10px 0;
}

.float_right {
  float: right;
}

.editable-row-operations a {
  margin-right: 8px;
}

.necessaryBefore {
  display: inline-block;
  margin-right: 4px;
  color: #f5222d;
  font-size: 14px;
  font-family: SimSun, sans-serif;
  line-height: 1;
  content: "*";
}

.necessary {
  /deep/.ant-descriptions-row {
    &:nth-of-type(1) {
      .ant-descriptions-item {
        &:nth-of-type(1),
        &:nth-of-type(2),
        &:nth-of-type(3) {
          .ant-descriptions-item-label.ant-descriptions-item-colon {
            &:before {
              .necessaryBefore();
            }
          }
        }
      }
    }
    &:nth-of-type(2) {
      .ant-descriptions-item {
        &:nth-of-type(1) {
          .ant-descriptions-item-label.ant-descriptions-item-colon {
            &:before {
              .necessaryBefore();
            }
          }
        }
      }
    }
    &:nth-of-type(3) {
      .ant-descriptions-item {
        &:nth-of-type(1) {
          .ant-descriptions-item-label.ant-descriptions-item-colon {
            &:before {
              .necessaryBefore();
            }
          }
        }
      }
    }
    &:nth-of-type(5) {
      .ant-descriptions-item {
        &:nth-of-type(1) {
          .ant-descriptions-item-label.ant-descriptions-item-colon {
            &:before {
              .necessaryBefore();
            }
          }
        }
      }
    }
    &:nth-of-type(11) {
      .ant-descriptions-item {
        &:nth-of-type(3) {
          .ant-descriptions-item-label.ant-descriptions-item-colon {
            &:before {
              .necessaryBefore();
            }
          }
        }
      }
    }
  }
}
.require {
  /deep/.ant-descriptions-row {
    &:nth-of-type(5) {
      .ant-descriptions-item {
        &:nth-of-type(2) {
          .ant-descriptions-item-label.ant-descriptions-item-colon {
            &:before {
              .necessaryBefore();
            }
          }
        }
      }
    }
  }
}
.required {
  /deep/.ant-descriptions-row {
    &:nth-of-type(3) {
      .ant-descriptions-item {
        &:nth-of-type(2) {
          .ant-descriptions-item-label.ant-descriptions-item-colon {
            &:before {
              .necessaryBefore();
            }
          }
        }
      }
    }
  }
}
</style>